package com.heima.sjms.原型模式;

/**
 * @author 陈辉
 * @data 2023 9:17
 */
public class Student implements Cloneable{

    private String name;
    private int age;
    private cls cls;

    @Override
    public Student clone() throws CloneNotSupportedException {
        Student newStu = (Student) super.clone();
        cls newCls = newStu.getCls().clone();
        newStu.setCls(newCls);

        return newStu;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", cls=" + cls +
                '}';
    }

    public com.heima.sjms.原型模式.cls getCls() {
        return cls;
    }

    public void setCls(com.heima.sjms.原型模式.cls cls) {
        this.cls = cls;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}


class cls implements Cloneable{
    private String cname;

    @Override
    public String toString() {
        return "cls{" +
                "cname='" + cname + '\'' +
                '}';
    }

    @Override
    public cls clone() throws CloneNotSupportedException {
        return (cls) super.clone();
    }

    public String getCname() {
        return cname;
    }

    public void setCname(String cname) {
        this.cname = cname;
    }
}